<?php namespace app\home\controller;

use houdunwang\view\View;

class Entry extends Common {

	public function index() {
	    //页面title
	    $headConf = ['title'=>'媒体博客--首页'];
	    View::with('headConf',$headConf);

	    //获取文章的内容信息cid
          $articleData = Db::table('article')->join('category','category_cid','=','cid')->where('is_recycle',0)
              ->field('aid,title,author,sendtime,thumb,digest,cid,cname')->limit(3)->get();

          foreach($articleData as $k=>$v){
              //ofTag因为可能有多个标签，所以它是一个数组，用lists()
              $articleData[$k]['ofTag'] = Db::table('article_tag')->join('tag','tag_tid','=','tid')
                  ->where('article_aid',$v['aid'])->lists('tid,tname');
          }
            //p($articleData);
            View::with('articleData',$articleData);
          //p($allCateData);
		return view();
	}
}